package com.demo;

import com.demo.component.BeanLifeComponent;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2023-05-26
 * Time:23:14
 */
public class App2 {
    public static void main(String[] args) {
        //获得上下文用这个方法ClassPathXmlApplicationContext而不用ApplicationContext是因为ClassPathXmlApplicationContext这个中有销毁方法
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");

        BeanLifeComponent beanLifeComponent = context.getBean("myComponent",BeanLifeComponent.class);
        System.out.println("使用 Bean");

        //销毁 Bean 直接销毁容器
        context.destroy();
    }
}
